#ifndef MYTHREAD_H_
#define MYTHREAD_H_

#include<iostream>
#include<thread>
#include<atomic>

class ThreadPool;

class Mythread
{
public:
    enum class StatusCode{STOP=0,RUN,BLOCK};

    struct ThreadStatus
    {
        int _tid;
        StatusCode _code;   //运行状态码
    };

public:
    Mythread(int id);

    ~Mythread();

    Mythread(const Mythread&)=delete;


    Mythread& operator=(const Mythread&)=delete;


    Mythread(Mythread&&);


    Mythread& operator=(Mythread&&);



    int invoke(ThreadPool&);   //线程启动
    int close();    //线程关闭

    Mythread::ThreadStatus CheckThrreadStatus();    //查看线程状态


private:
    void MainThread(ThreadPool&);          //线程入口函数


private:
    std::atomic<StatusCode> _status;  //线程状态说明
    std::thread* _t_handel;      //线程id
    int _tid;           //线程编号       
};


#endif